package com.zxu.test.activity;

import android.view.View;

import androidx.databinding.ObservableField;
import androidx.lifecycle.MutableLiveData;

import com.zxu.test.base.BaseViewModel;
import com.zxu.test.studyapp.R;
import com.zxu.test.util.DoubleClickUtils;
import com.zxu.test.util.Event;

public class ActionViewModel extends BaseViewModel {

    public final ObservableField<String> btnEvent = new ObservableField<>();
    public final ObservableField<Event<String>> rxEvent = new ObservableField<>();
    public final ObservableField<Event<String>> cancelEvent = new ObservableField<>();
    public final ObservableField<Event<String>> saveEvent = new ObservableField<>();
    private final MutableLiveData<Event<Object>> btBroadcastEvent = new MutableLiveData<>();
    public final ObservableField<String> tv_ac = new ObservableField<>();

    MutableLiveData<Event<Object>> getBroadcastCommand() {
        return btBroadcastEvent;
    }

    public ActionViewModel() {
        start();
    }

    private void start() {
    }

    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt1:
                if (!DoubleClickUtils.isFastDoubleClick(R.id.bt1))
                    btnEvent.set("sss");
                break;
            case R.id.bt2:
                if (!DoubleClickUtils.isFastDoubleClick(R.id.bt2))
                    rxEvent.set(new Event<>(""));
                break;
            case R.id.bt3:
                if (!DoubleClickUtils.isFastDoubleClick(R.id.bt3))
                    cancelEvent.set(new Event<>(""));
                break;
            case R.id.bt4:
                if (!DoubleClickUtils.isFastDoubleClick(R.id.bt4))
                    saveEvent.set(new Event<>(""));
                break;
            case R.id.bt5:
                if (!DoubleClickUtils.isFastDoubleClick(R.id.bt5))
                    btBroadcastEvent.setValue(new Event<>("aaa"));
                break;

        }
    }

}
